package com.isay.frameworklib.widget.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;

import com.isay.frameworklib.R;

/**
 * Created by cywu4 on 2018/12/27.
 */
public class MessageBox extends Dialog implements View.OnClickListener {


    private MDialogListener mDialogListener;

    public interface MDialogListener {
        void onSure();
    }

    public void setListener(MDialogListener l) {
        mDialogListener = l;
    }



    public MessageBox(Context context) {
        super(context, R.style.AlertDlgStyle);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        View view = LayoutInflater.from(context).inflate(R.layout.dialog_view_common, null);
        view.findViewById(R.id.tv_cancel).setOnClickListener(this);
        view.findViewById(R.id.tv_sure).setOnClickListener(this);
        setContentView(view);
        setCancelable(false);
    }


    @Override
    public void onClick(View view) {
        int id = view.getId();
        if (id == R.id.tv_cancel) {
            dismiss();
        } else if (id == R.id.tv_sure) {
            if (mDialogListener != null) {
                mDialogListener.onSure();
            }
            dismiss();
        }

    }
}
